package NetWork;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

/**
 * Tcp版本的翻译程序
 */
public class TcpDictServer extends TcpThreadPoolEchoServer {
    private HashMap<String,String> dict = new HashMap<>();

    public TcpDictServer(int port) throws IOException {
        super(port);

        //简单构造几个词
        dict.put("cat","小猫");
        dict.put("dog","小狗");
        dict.put("pig","猪猪");
        dict.put("duck","鸭");
    }

    public String process(String requset){
        return  dict.getOrDefault(requset,"该词无法被翻译！");
    }

    public static void main(String[] args) throws IOException {
        TcpDictServer server = new TcpDictServer(9090);
        server.start();
    }
}
